<?php

namespace App\Http\Requests\System;

use App\Http\Requests\BaseRequest;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class User extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => [
                'required',
                Rule::unique('users')
                    ->ignore(request()->user)
                    ->where(function ($query){
                        $query->whereNull('deleted_at');
                    }),
            ]
        ];
    }

    public function messages(){
        return [
            'username.required' => '请输入登录账户',
            'username.unique' => '登录账户重复',
        ];
    }
}
